#!/bin/bash
## kola:
##   exclusive: false
##   description: Verify all initrd scripts are executable.

set -xeuo pipefail

# shellcheck disable=SC1091
. "$KOLA_EXT_DATA/commonlib.sh"

tmpd=$(mktemp -d)
( cd "${tmpd}" && lsinitrd --unpack /boot/ostree/*/init* )
if find "${tmpd}/usr/"{bin,sbin,libexec} ! -perm -0111 | grep -v clevis-luks-common-functions; then
    fatal "Found non-executable scripts in initrd"
fi
rm -r "${tmpd}"
ok "All initrd scripts are executable"
